#include <stdio.h>
#include <stdlib.h>






/*
 *for(;;) ==>while
 * */
void test1(void)
{
	int i = 0;
	int end = 10;
	int sum = 0;
	
	for( ;;)
	{
		sum += i;
		i++;
		if (i > end)
		{
			break;
		}
	}
	

	printf("sum = %d\n",sum);


}

/*
 *for 中exp允许多个条件判断循环是否继续 
 * */
void test2(void)
{
	int i,j,sum = 0,i_sum = 0,j_sum = 0;/*auto类型的变量必须初始化初始化;不初始化数值乱标*/	
	for (i=0,j=0;i<10,j<10;i++,j++)
	{
		i_sum+=i; 
		j_sum+=j;
		sum+=(i+j);
		printf("i = %d,j = %d\n",i,j);	
		printf("i_sum = %d\n",i_sum);	
		printf("j_sum = %d\n",j_sum);
	}
	printf("sum = %d\n",sum);
	printf("i_sum = %d,j_sum = %d\n",i_sum,j_sum);// 55 45
}


int main(void)
{
	
	test1();
	test2();
	exit(0);
}
